home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Dialogs.h
-
- Contains: Dialog Manager interfaces.
-
- Version: Technology: System 7.5
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __DIALOGS__
- #define __DIALOGS__
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
- #ifndef __CONTROLS__
- #include <Controls.h>
- #endif
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
- #ifndef __TEXTEDIT__
- #include <TextEdit.h>
- #endif
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
-
- enum {
- ctrlItem = 4,
- btnCtrl = 0,
- chkCtrl = 1,
- radCtrl = 2,
- resCtrl = 3,
- statText = 8,
- editText = 16,
- iconItem = 32,
- picItem = 64,
- userItem = 0,
- itemDisable = 128,
- ok = 1,
- cancel = 2,
- stopIcon = 0,
- noteIcon = 1,
- cautionIcon = 2
- };
-
-
- enum {
- /* new, more standard names for dialog item constants */
- kControlDialogItem = 4,
- kButtonDialogItem = kControlDialogItem | 0,
- kCheckBoxDialogItem = kControlDialogItem | 1,
- kRadioButtonDialogItem = kControlDialogItem | 2,
- kResourceControlDialogItem = kControlDialogItem | 3,
- kStaticTextDialogItem = 8,
- kEditTextDialogItem = 16,
- kIconDialogItem = 32,
- kPictureDialogItem = 64,
- kUserDialogItem = 0, /* misc. constants */
- kItemDisableBit = 128,
- kStdOkItemIndex = 1,
- kStdCancelItemIndex = 2, /* standard icon resource id's */
- kStopIcon = 0,
- kNoteIcon = 1,
- kCautionIcon = 2
- };
-
- #if OLDROUTINENAMES
- /*
- These constants lived briefly on ETO 16. They suggest
- that there is only one index you can use for the OK
- item, which is not true. You can put the ok item
- anywhere you want in the DITL.
- */
-
- enum {
- kOkItemIndex = 1,
- kCancelItemIndex = 2
- };
-
- #endif
- /* Dialog Item List Manipulation Constants */
- typedef SInt16 DITLMethod;
-
- enum {
- overlayDITL = 0,
- appendDITLRight = 1,
- appendDITLBottom = 2
- };
-
- typedef SInt16 StageList;
- typedef DialogPtr DialogRef;
- struct DialogRecord {
- WindowRecord window;
- Handle items;
- TEHandle textH;
- SInt16 editField;
- SInt16 editOpen;
- SInt16 aDefItem;
- };
- typedef struct DialogRecord DialogRecord;
-
- typedef DialogRecord *DialogPeek;
- struct DialogTemplate {
- Rect boundsRect;
- SInt16 procID;
- Boolean visible;
- Boolean filler1;
- Boolean goAwayFlag;
- Boolean filler2;
- SInt32 refCon;
- SInt16 itemsID;
- Str255 title;
- };
- typedef struct DialogTemplate DialogTemplate;
-
- typedef DialogTemplate *DialogTPtr;
- typedef DialogTPtr *DialogTHndl;
- struct AlertTemplate {
- Rect boundsRect;
- SInt16 itemsID;
- StageList stages;
- };
- typedef struct AlertTemplate AlertTemplate;
-
- typedef AlertTemplate *AlertTPtr;
- typedef AlertTPtr *AlertTHndl;
- /* new type abstractions for the dialog manager */
- typedef SInt16 DialogItemIndexZeroBased;
- typedef SInt16 DialogItemIndex;
- typedef SInt16 DialogItemType;
- /* dialog manager callbacks */
- typedef pascal void (*SoundProcPtr)(SInt16 soundNumber);
-
- #if GENERATINGCFM
- typedef UniversalProcPtr SoundUPP;
- #else
- typedef SoundProcPtr SoundUPP;
- #endif
-
- enum {
- uppSoundProcInfo = kPascalStackBased
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SInt16)))
- };
-
- #if GENERATINGCFM
- #define NewSoundProc(userRoutine) \
- (SoundUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSoundProcInfo, GetCurrentArchitecture())
- #else
- #define NewSoundProc(userRoutine) \
- ((SoundUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallSoundProc(userRoutine, soundNumber) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppSoundProcInfo, (soundNumber))
- #else
- #define CallSoundProc(userRoutine, soundNumber) \
- (*(userRoutine))((soundNumber))
- #endif
- typedef pascal Boolean (*ModalFilterProcPtr)(DialogRef theDialog, EventRecord *theEvent, DialogItemIndex *itemHit);
-
- #if GENERATINGCFM
- typedef UniversalProcPtr ModalFilterUPP;
- #else
- typedef ModalFilterProcPtr ModalFilterUPP;
- #endif
-
- enum {
- uppModalFilterProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DialogRef)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(EventRecord *)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(DialogItemIndex *)))
- };
-
- #if GENERATINGCFM
- #define NewModalFilterProc(userRoutine) \
- (ModalFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppModalFilterProcInfo, GetCurrentArchitecture())
- #else
- #define NewModalFilterProc(userRoutine) \
- ((ModalFilterUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppModalFilterProcInfo, (theDialog), (theEvent), (itemHit))
- #else
- #define CallModalFilterProc(userRoutine, theDialog, theEvent, itemHit) \
- (*(userRoutine))((theDialog), (theEvent), (itemHit))
- #endif
- typedef pascal void (*UserItemProcPtr)(WindowRef theWindow, DialogItemIndex itemNo);
-
- #if GENERATINGCFM
- typedef UniversalProcPtr UserItemUPP;
- #else
- typedef UserItemProcPtr UserItemUPP;
- #endif
-
- enum {
- uppUserItemProcInfo = kPascalStackBased
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowRef)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogItemIndex)))
- };
-
- #if GENERATINGCFM
- #define NewUserItemProc(userRoutine) \
- (UserItemUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUserItemProcInfo, GetCurrentArchitecture())
- #else
- #define NewUserItemProc(userRoutine) \
- ((UserItemUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallUserItemProc(userRoutine, theWindow, itemNo) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppUserItemProcInfo, (theWindow), (itemNo))
- #else
- #define CallUserItemProc(userRoutine, theWindow, itemNo) \
- (*(userRoutine))((theWindow), (itemNo))
- #endif
- /*
- NOTE: Code running under MultiFinder or System 7.0 or newer
- should always pass NULL to InitDialogs.
- */
- extern pascal void InitDialogs(void *ignored)
- ONEWORDINLINE(0xA97B);
-
- extern pascal void ErrorSound(SoundUPP soundProc)
- ONEWORDINLINE(0xA98C);
-
- extern pascal DialogRef NewDialog(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, SInt16 procID, WindowRef behind, Boolean goAwayFlag, SInt32 refCon, Handle itmLstHndl)
- ONEWORDINLINE(0xA97D);
-
- extern pascal DialogRef GetNewDialog(SInt16 dialogID, void *dStorage, WindowRef behind)
- ONEWORDINLINE(0xA97C);
-
- extern pascal DialogRef NewColorDialog(void *dStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, SInt16 procID, WindowRef behind, Boolean goAwayFlag, SInt32 refCon, Handle items)
- ONEWORDINLINE(0xAA4B);
-
- extern pascal void CloseDialog(DialogRef theDialog)
- ONEWORDINLINE(0xA982);
-
- extern pascal void DisposeDialog(DialogRef theDialog)
- ONEWORDINLINE(0xA983);
-
- extern pascal void ModalDialog(ModalFilterUPP modalFilter, DialogItemIndex *itemHit)
- ONEWORDINLINE(0xA991);
-
- extern pascal Boolean IsDialogEvent(const EventRecord *theEvent)
- ONEWORDINLINE(0xA97F);
-
- extern pascal Boolean DialogSelect(const EventRecord *theEvent, DialogRef *theDialog, DialogItemIndex *itemHit)
- ONEWORDINLINE(0xA980);
-
- extern pascal void DrawDialog(DialogRef theDialog)
- ONEWORDINLINE(0xA981);
-
- extern pascal void UpdateDialog(DialogRef theDialog, RgnHandle updateRgn)
- ONEWORDINLINE(0xA978);
-
- extern pascal void HideDialogItem(DialogRef theDialog, DialogItemIndex itemNo)
- ONEWORDINLINE(0xA827);
-
- extern pascal void ShowDialogItem(DialogRef theDialog, DialogItemIndex itemNo)
- ONEWORDINLINE(0xA828);
-
- extern pascal DialogItemIndexZeroBased FindDialogItem(DialogRef theDialog, Point thePt)
- ONEWORDINLINE(0xA984);
-
- extern pascal void DialogCut(DialogRef theDialog);
-
- extern pascal void DialogPaste(DialogRef theDialog);
-
- extern pascal void DialogCopy(DialogRef theDialog);
-
- extern pascal void DialogDelete(DialogRef theDialog);
-
- extern pascal DialogItemIndex Alert(SInt16 alertID, ModalFilterUPP modalFilter)
- ONEWORDINLINE(0xA985);
-
- extern pascal DialogItemIndex StopAlert(SInt16 alertID, ModalFilterUPP modalFilter)
- ONEWORDINLINE(0xA986);
-
- extern pascal DialogItemIndex NoteAlert(SInt16 alertID, ModalFilterUPP modalFilter)
- ONEWORDINLINE(0xA987);
-
- extern pascal DialogItemIndex CautionAlert(SInt16 alertID, ModalFilterUPP modalFilter)
- ONEWORDINLINE(0xA988);
-
- extern pascal void GetDialogItem(DialogRef theDialog, DialogItemIndex itemNo, DialogItemType *itemType, Handle *item, Rect *box)
- ONEWORDINLINE(0xA98D);
-
- extern pascal void SetDialogItem(DialogRef theDialog, DialogItemIndex itemNo, DialogItemType itemType, Handle item, const Rect *box)
- ONEWORDINLINE(0xA98E);
-
- extern pascal void ParamText(ConstStr255Param param0, ConstStr255Param param1, ConstStr255Param param2, ConstStr255Param param3)
- ONEWORDINLINE(0xA98B);
-
- extern pascal void SelectDialogItemText(DialogRef theDialog, DialogItemIndex itemNo, SInt16 strtSel, SInt16 endSel)
- ONEWORDINLINE(0xA97E);
-
- extern pascal void GetDialogItemText(Handle item, Str255 text)
- ONEWORDINLINE(0xA990);
-
- extern pascal void SetDialogItemText(Handle item, ConstStr255Param text)
- ONEWORDINLINE(0xA98F);
-
- extern pascal SInt16 GetAlertStage(void)
- TWOWORDINLINE(0x3EB8, 0x0A9A);
-
- extern DialogRef newdialog(void *wStorage, const Rect *boundsRect, const char *title, Boolean visible, SInt16 procID, WindowRef behind, Boolean goAwayFlag, SInt32 refCon, Handle itmLstHndl);
-
- extern DialogRef newcolordialog(void *dStorage, const Rect *boundsRect, const char *title, Boolean visible, SInt16 procID, WindowRef behind, Boolean goAwayFlag, SInt32 refCon, Handle items);
-
- extern pascal void SetDialogFont(SInt16 value)
- TWOWORDINLINE(0x31DF, 0x0AFA);
-
- extern pascal void ResetAlertStage(void )
- TWOWORDINLINE(0x4278, 0x0A9A);
-
- #if CGLUESUPPORTED
- extern void paramtext(const char *param0, const char *param1, const char *param2, const char *param3);
-
- extern void getdialogitemtext(Handle item, char *text);
-
- extern void setdialogitemtext(Handle item, const char *text);
-
- extern DialogItemIndexZeroBased finddialogitem(DialogRef theDialog, Point *thePt);
-
- #endif
- extern pascal void AppendDITL(DialogRef theDialog, Handle theHandle, DITLMethod method);
-
- extern pascal DialogItemIndex CountDITL(DialogRef theDialog);
-
- extern pascal void ShortenDITL(DialogRef theDialog, DialogItemIndex numberItems);
-
- extern pascal Boolean StdFilterProc(DialogRef theDialog, EventRecord *event, DialogItemIndex *itemHit);
-
- extern pascal OSErr GetStdFilterProc(ModalFilterUPP *theProc)
- THREEWORDINLINE(0x303C, 0x0203, 0xAA68);
-
- extern pascal OSErr SetDialogDefaultItem(DialogRef theDialog, DialogItemIndex newItem)
- THREEWORDINLINE(0x303C, 0x0304, 0xAA68);
-
- extern pascal OSErr SetDialogCancelItem(DialogRef theDialog, DialogItemIndex newItem)
- THREEWORDINLINE(0x303C, 0x0305, 0xAA68);
-
- extern pascal OSErr SetDialogTracksCursor(DialogRef theDialog, Boolean tracks)
- THREEWORDINLINE(0x303C, 0x0306, 0xAA68);
-
- #if OLDROUTINENAMES
- #define DisposDialog(theDialog) DisposeDialog(theDialog)
- #define UpdtDialog(theDialog, updateRgn) UpdateDialog(theDialog, updateRgn)
- #define GetDItem(theDialog, itemNo, itemType, item, box) GetDialogItem(theDialog, itemNo, itemType, item, box)
- #define SetDItem(theDialog, itemNo, itemType, item, box) SetDialogItem(theDialog, itemNo, itemType, item, box)
- #define HideDItem(theDialog, itemNo) HideDialogItem(theDialog, itemNo)
- #define ShowDItem(theDialog, itemNo) ShowDialogItem(theDialog, itemNo)
- #define SelIText(theDialog, itemNo, strtSel, endSel) SelectDialogItemText(theDialog, itemNo, strtSel, endSel)
- #define GetIText(item, text) GetDialogItemText(item, text)
- #define SetIText(item, text) SetDialogItemText(item, text)
- #define FindDItem(theDialog, thePt) FindDialogItem(theDialog, thePt)
- #define NewCDialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items) \
- NewColorDialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)
- #define GetAlrtStage() GetAlertStage()
- #define ResetAlrtStage() ResetAlertStage()
- #define DlgCut(theDialog) DialogCut(theDialog)
- #define DlgPaste(theDialog) DialogPaste(theDialog)
- #define DlgCopy(theDialog) DialogCopy(theDialog)
- #define DlgDelete(theDialog) DialogDelete(theDialog)
- #define SetDAFont(fontNum) SetDialogFont(fontNum)
- #if CGLUESUPPORTED
- #define newcdialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items) \
- newcolordialog(dStorage, boundsRect, title, visible, procID, behind, goAwayFlag, refCon, items)
- #define getitext(item, text) getdialogitemtext(item, text)
- #define setitext(item, text) setdialogitemtext(item, text)
- #define findditem(theDialog, thePt) finddialogitem(theDialog, thePt)
- #endif
- #endif
- /*
- *****************************************************************************
- * *
- * The conditional STRICT_DIALOGS has been removed from this interface file. *
- * The accessor macros to a DialogRecord are no longer necessary. *
- * *
- *****************************************************************************
-
- Details:
- The original purpose of the STRICT_ conditionals and accessor macros was to
- help ease the transition to Copland. Shared data structures are difficult
- to coordinate in a preemptive multitasking OS. By hiding the fields in a
- WindowRecord and other data structures, we would begin the migration to
- system data structures being completely hidden from applications.
-
- After many design reviews, it was finally concluded that with this sort of
- migration, the system could never tell when an application was no longer
- peeking at a WindowRecord, and thus the data structure might never become
- system owned. Additionally, there were many other limitations in the classic
- toolbox that were begging to be addressed.
-
- The final decision was to leave the traditional toolbox as a compatibility mode.
- The preferred toolbox API for Copland is a new SOM(tm) based architecture
- (e.g. HIWindows.idl). Windows, menu, controls, etc are each a SOM object
- with methods for drawing, event handling, and customization.
-
- */
- #ifdef __cplusplus
- inline WindowRef GetDialogWindow(DialogRef dialog) { return (WindowRef) dialog; }
- inline SInt16 GetDialogDefaultItem(DialogRef dialog) { return (*(SInt16 *) (((UInt8 *) dialog) + 168)); }
- inline SInt16 GetDialogCancelItem(DialogRef dialog) { return (*(SInt16 *) (((UInt8 *) dialog) + 166)); }
- inline SInt16 GetDialogKeyboardFocusItem(DialogRef dialog) { return ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ? -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1); }
- inline void SetGrafPortOfDialog(DialogRef dialog) { SetPort ((GrafPtr) dialog); }
- #else
- #define GetDialogWindow(dialog) ((WindowRef) dialog)
- #define GetDialogDefaultItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 168))
- #define GetDialogCancelItem(dialog) (*(SInt16 *) (((UInt8 *) dialog) + 166))
- #define GetDialogKeyboardFocusItem(dialog) ((*(SInt16 *) (((UInt8 *) dialog) + 164)) < 0 ? -1 : (*(SInt16 *) (((UInt8 *) dialog) + 164)) + 1)
- #define SetGrafPortOfDialog(dialog) do { SetPort ((GrafPtr) dialog); } while (false);
- #endif
- #endif
- #if FOR_SYSTEM7_ONLY
- extern pascal void CouldDialog(SInt16 dialogID)
- ONEWORDINLINE(0xA979);
-
- extern pascal void FreeDialog(SInt16 dialogID)
- ONEWORDINLINE(0xA97A);
-
- extern pascal void CouldAlert(SInt16 alertID)
- ONEWORDINLINE(0xA989);
-
- extern pascal void FreeAlert(SInt16 alertID)
- ONEWORDINLINE(0xA98A);
-
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __DIALOGS__ */
-
-